from django.contrib.sitemaps import Sitemap, GenericSitemap
from biologeek.journal.models import Post
from biologeek.bistrot.models import Thought

class BaseSitemap(Sitemap):
    priority = 0.8

    def items(self):
        return ['/', '/journal/', '/bistrot/', '/archives/', '/abonnement/', '/contact/']

    def location(self, obj):
        return obj


sitemaps = {
    'base': BaseSitemap(),
    'journal_bestof': GenericSitemap(
        {
            'queryset': Post.published.filter(is_bestof=True),
            'date_field': 'publication_date'
        },
        priority=0.6
    ),
    'journal': GenericSitemap(
        {
            'queryset': Post.published.exclude(is_bestof=True),
            'date_field': 'publication_date'
        },
        priority=0.4
    ),
    'bistrot': GenericSitemap(
        {
            'queryset': Thought.published.all(),
            'date_field': 'publication_date'
        },
        priority=0.2
    ),
}

